package com.bwie.gddproject.index.view;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.widget.FrameLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;

import com.bwie.gddproject.R;
import com.bwie.gddproject.base.BaseActivity;
import com.bwie.gddproject.index.view.fragment.ClassifyFragment;
import com.bwie.gddproject.index.view.fragment.FindFragment;
import com.bwie.gddproject.index.view.fragment.IndexFragment;
import com.bwie.gddproject.index.view.fragment.MyFragment;
import com.bwie.gddproject.index.view.fragment.ShopCarFragment;
import com.bwie.gddproject.login.model.LoginBean;
import com.hjm.bottomtabbar.BottomTabBar;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class IndexActivity extends BaseActivity {
    private List<Fragment> fragments = new ArrayList<>();
    private FrameLayout mFrame;
    /**
     * 首页
     */
    private RadioButton mRgBt1;
    /**
     * 分类
     */
    private RadioButton mRgBt2;
    /**
     * 发现
     */
    private RadioButton mRgBt3;
    /**
     * 购物车
     */
    private RadioButton mRgBt4;
    /**
     * 我的
     */
    private RadioButton mRgBt5;
    private RadioGroup mIndexRg;
    private ClassifyFragment classifyFragment;
    private FindFragment findFragment;
    private IndexFragment indexFragment;
    private MyFragment myFragment;
    private ShopCarFragment shopCarFragment;
    private BottomTabBar mBottomBar;
    private RelativeLayout mActivityIndex;
    private LoginBean loginBean;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_index);
        initView();
//        Intent intent = getIntent();
//        Bundle extras = intent.getExtras();
//        myFragment.setArguments(extras);


        mBottomBar.init(getSupportFragmentManager())
                .setImgSize(100, 100)
                .setFontSize(0)
                .setTabPadding(2, 4, 6)
                .setChangeColor(Color.RED, Color.DKGRAY)
                .addTabItem("首页", R.drawable.index_selector, IndexFragment.class)
                .addTabItem("分类", R.drawable.classify_selector, ClassifyFragment.class)
                .addTabItem("发现", R.drawable.find_selector, FindFragment.class)
                .addTabItem("购物车", R.drawable.shopcar_selector, ShopCarFragment.class)
                .addTabItem("我的", R.drawable.my_selector, MyFragment.class)
                .isShowDivider(false)
                .setOnTabChangeListener(new BottomTabBar.OnTabChangeListener() {
                    @Override
                    public void onTabChange(int position, String name) {

                    }
                });
//        if (Build.VERSION.SDK_INT >= 21) {
//            View decorView = getWindow().getDecorView();
//            int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
//                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
//            decorView.setSystemUiVisibility(option);
//            getWindow().setStatusBarColor(Color.TRANSPARENT);
//        }
//        ActionBar actionBar = getSupportActionBar();
//        actionBar.hide();
//        initView();
//        setFragment(indexFragment);
//        mRgBt1.setChecked(true);
//        mIndexRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
//            @Override
//            public void onCheckedChanged(RadioGroup radioGroup, int i) {
//                switch (i){
//                    case R.id.rg_bt1:
//                    setFragment(indexFragment);
//                        break;
//                    case R.id.rg_bt2:
//                        setFragment(classifyFragment);
//                        break;
//                    case R.id.rg_bt3:
//                        setFragment(findFragment);
//                        break;
//                    case R.id.rg_bt4:
//                        setFragment(shopCarFragment);
//                        break;
//                    case R.id.rg_bt5:
//                        setFragment(myFragment);
//                        break;
//                }
//            }
//        });
//
//    }
//
//    @Override
//    protected void onDestroy() {
//        super.onDestroy();
//        ActivityStroeUtil.finishAllActivity();
//    }
//
//    private void initView() {
//        mFrame = (FrameLayout) findViewById(R.id.frame);
//        mRgBt1 = (RadioButton) findViewById(R.id.rg_bt1);
//        mRgBt2 = (RadioButton) findViewById(R.id.rg_bt2);
//        mRgBt3 = (RadioButton) findViewById(R.id.rg_bt3);
//        mRgBt4 = (RadioButton) findViewById(R.id.rg_bt4);
//        mRgBt5 = (RadioButton) findViewById(R.id.rg_bt5);
//        mIndexRg = (RadioGroup) findViewById(R.id.index_rg);
//        classifyFragment = new ClassifyFragment();
//        findFragment = new FindFragment();
//        indexFragment = new IndexFragment();
//        myFragment = new MyFragment();
//        shopCarFragment = new ShopCarFragment();
//        fragments.add(classifyFragment);
//        fragments.add(findFragment);
//        fragments.add(indexFragment);
//        fragments.add(myFragment);
//        fragments.add(shopCarFragment);
//    }
//
//    //设置默认显示Fragment
//    private void setFragment(Fragment fragment) {
//        FragmentManager fragmentManager = getSupportFragmentManager();
//        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
//        fragmentTransaction.show(fragment);
//        fragmentTransaction.replace(R.id.frame, fragment);
//        fragmentTransaction.commit();
//
//    }
    }

    private void initView() {
        mBottomBar = (BottomTabBar) findViewById(R.id.bottom_bar);
        mActivityIndex = (RelativeLayout) findViewById(R.id.activity_index);
    }
    public LoginBean getUserInFo(){
        return loginBean;
    }


}
